package com.business_clean.ui.adapter.attendance;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.business_clean.R;
import com.business_clean.app.weight.CustomAvatarView;
import com.business_clean.data.mode.attendance.AttendanceListEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class DateAttendanceAdapter extends BaseQuickAdapter<AttendanceListEntity, BaseViewHolder> {

    public DateAttendanceAdapter() {
        super(R.layout.item_date_attendance);
        addChildClickViewIds(R.id.iv_item_roster_edit);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, AttendanceListEntity item) {
        holder.setText(R.id.tv_item_roster_name, item.getUser_name());
        TextView tvDesc = holder.getView(R.id.tv_item_roster_phone);

        CustomAvatarView avatarView = holder.getView(R.id.iv_item_roster_avatar);
        avatarView.setAvatar(item.getAvatar(), item.getUser_name());
        avatarView.getAvatarText().setTextSize(16f);

        //在这里呀哦区分身份 如果是保洁员，那么就显示基本信息
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(item.getSex_name())) {
            stringBuilder.append(item.getSex_name());
        }
        if (!TextUtils.isEmpty(item.getJob_name())) {
            stringBuilder.append(" / ").append(item.getJob_name());
        }
        if (!TextUtils.isEmpty(item.getClass_name())) {
            stringBuilder.append(" / ").append(item.getClass_name());
        }
        tvDesc.setText(stringBuilder.toString());

        if ("1".equals(item.getIs_absenteeism())) {
            holder.getView(R.id.tv_item_attendance_absenteeism).setVisibility(View.VISIBLE);//旷工
        } else {
            holder.getView(R.id.tv_item_attendance_absenteeism).setVisibility(View.GONE);//旷工
        }

        if ("1".equals(item.getIs_qk())) {
            holder.getView(R.id.tv_item_attendance_miss_card).setVisibility(View.VISIBLE);//缺卡
        } else {
            holder.getView(R.id.tv_item_attendance_miss_card).setVisibility(View.GONE);//缺卡

        }

        if ("1".equals(item.getIs_attendance())) {
            holder.getView(R.id.tv_item_attendance_days).setVisibility(View.VISIBLE);//出勤
        } else {
            holder.getView(R.id.tv_item_attendance_days).setVisibility(View.GONE);//出勤
        }


        if ("1".equals(item.getIs_overtime())) {
            holder.getView(R.id.tv_item_attendance_overtime).setVisibility(View.VISIBLE);//加班
        } else {
            holder.getView(R.id.tv_item_attendance_overtime).setVisibility(View.GONE);//加班
        }


        if ("1".equals(item.getIs_rest())) {
            holder.getView(R.id.tv_item_attendance_rest).setVisibility(View.VISIBLE);//休息
        } else {
            holder.getView(R.id.tv_item_attendance_rest).setVisibility(View.GONE);//休息
        }


        if ("1".equals(item.getIs_holiday())) {
            holder.getView(R.id.tv_item_attendance_holiday).setVisibility(View.VISIBLE);//休假
        } else {
            holder.getView(R.id.tv_item_attendance_holiday).setVisibility(View.GONE);//休假
        }

    }
}
